import { REGISTER_REQUEST, REGISTER_SUCCESS, REGISTER_FAILURE } from 'actions';

const register = (state = { loading: false, data: null, error: null }, action) => {
  switch (action.type) {
    case REGISTER_REQUEST:
      return Object.assign({}, state, { loading: true });
    case REGISTER_SUCCESS:
      return Object.assign({}, state, { loading: false, data: action.data, error: null });
    case REGISTER_FAILURE:
      return Object.assign({}, state, { loading: false, data: null, error: action.error });
    default:
      return state;
  }
};

export default register;
